package cn.initcap.concurrency;

import cn.initcap.concurrency.concurrency.threadlocal.RequestHolder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author initcap
 * @date Created in 2018/6/16 AM9:42.
 */
@Slf4j
public class HttpIntercepter extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("preHandle");
        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.info("affterCompletion");
        RequestHolder.remove();
    }
}
